package ssm.dao;

import utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public interface Search {
    default void run() {
        Statement stmt = null;
        Connection conn = null;
        ResultSet rs = null;

        try {
            conn = JDBCUtils.getConnection();
            stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs = stmt.executeQuery("SELECT * FROM  designs.source_code_info");
            check(conn, rs, JDBCUtils.getRow(rs));
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.close(rs, stmt, conn);
        }
    }

    void check(Connection conn, ResultSet rs, int rowsNumber) throws SQLException;
}
